package com.ie.controller;

import java.util.List;

import com.ie.entity.Pets;
import com.ie.service.PetsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/system/pets")
public class PetsController
{
    @Autowired
    private PetsService petsService;
    @GetMapping("/all")
    public List<Pets> getAllPets()
    {
        return petsService.getAllPets();
    }
    //修改状态
    @PutMapping("/update")
    public boolean updatePets(@RequestParam ("id") Integer id, @RequestParam("status") String status)
    {
        return petsService.updatePets(id, status);
    }
    //查询
    @GetMapping("/search")
    public List<Pets> searchPets(@RequestParam ("petname") String petname)
    {
        return petsService.searchPets(petname);
    }
    //添加
    @PostMapping("/add")

    public boolean addPets(@RequestBody Pets pets)
    {
        System.err.println(pets);
        return petsService.addPets(pets);
    }

    //修改申请领养
    @PutMapping("/updateApply")
    public boolean updateApply(@RequestParam ("id") Integer id, @RequestParam("username") String username){
        return petsService.updateApply(id,username);
    }
    //取消申请
    @PutMapping("/cancelApply")
    public boolean cancelApply(@RequestParam ("id") Integer id, @RequestParam("username") String username){
        return petsService.cancelApply(id,username);
    }

    //查询自己申请的
    @GetMapping("/getPets")
    public List<Pets> getPets(@RequestParam("username") String username){
        return petsService.getPets(username);
    }


}
